<template>
  <div class="login-phone">
    <el-form label-width="65px" :rules="rules" :model="phone" ref="phoneref">
      <el-form-item label="邮箱" prop="email">
        <el-input v-model="phone.email" />
      </el-form-item>
      <el-form-item prop="code">
        <div class="get-code">
          <el-input v-model="phone.code" />
          <el-button type="primary" @click="mailbox" class="get-botton-code"
            >获取验证码</el-button
          >
        </div>
      </el-form-item>
    </el-form>
  </div>
</template>

<script >
import { defineComponent, reactive, ref } from "vue";
import { rules } from "../config/phone";
// import { ElForm } from "element-plus";
import { useStore } from "vuex";

export default defineComponent({
  setup() {
    const phone = reactive({
      email: "",
      code: "",
    });
    const store = useStore();

    const phoneref = ref();
    const phoneactive = () => {
      phoneref.value?.validate((valid) => {
        if (valid) {
          // store.dispatch("loginModule/phoneLoginAction", { ...phone });
        }
      });
    };
    const mailbox = () => {
      phoneref.value?.validate((valid) => {
        console.log(valid);
        if (valid) {
          store.dispatch("loginModule/phoneLoginAction", { ...phone });
        }
      });
    };
    return {
      phone,
      rules,
      phoneref,
      phoneactive,
      mailbox,
    };
  },
});
</script>

<style scoped lang="less">
.get-code {
  display: flex;
}
.get-botton-code {
  margin-left: 8px;
}
</style>
